<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>

<div id="comments">
  <?php $this->comments()->to($comments); ?>
  <?php if ($comments->have()): ?>
    <div class="alert alert-info">
      <span id="commentCount"><?php $this->commentsNum(_t('暂无评论'), _t('仅有 1 条评论'), _t('已有 %d 条评论')); ?></span>
    </div>
    <?php $comments->listComments(array( 'replyWord'  =>  _t('<button type="button" class="btn btn-danger btn-xs mdi-content-reply reply-button"></button>'))); ?>
    <?php $comments->pageNav('&laquo; ', ' &raquo;',3,'...',
        array(
          'wrapClass'     =>  'pagination',
          'itemTag'       =>  'li',
          'textTag'       =>  'span',
          'currentClass'  =>  'active',
          'prevClass'     =>  'prev',
          'nextClass'     =>  'next'));  ?> 
  <?php endif; ?>
        
  <?php if($this->allow('comment')): ?>
  <div id="<?php $this->respondId(); ?>" class="respond panel panel-default">
    <div class="panel-body">
      <div class="cancel-comment-reply"><?php $comments->cancelReply(_t('<button type="button" class="btn btn-primary btn-xs btn-fab mdi-content-clear pull-right"></button>')); ?></div>
      <h3 id="response"><?php _e('添加新评论'); ?></h3>
      <form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form" class="form-horizontal">
        <?php if($this->user->hasLogin()): ?>
          <div class="form-group">
            <label class="col-sm-2 control-label required"><?php _e('登录身份'); ?></label>
            <div class="col-sm-2">
              <div class="form-control-wrapper">
                <label class="control-label "><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a></label>
              </div>
            </div>
            <div class="col-sm-7">
              <div class="form-control-wrapper">
                <label class="control-label "><a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a></label>
              </div>
            </div>
          </div>
        <?php else: ?>
          <div class="form-group">
            <label for="author" class="col-sm-2 control-label required"><?php _e('昵称'); ?></label>
            <div class="col-sm-9">
              <div class="form-control-wrapper">
                <input type="text" name="author" id="author" class="form-control text empty" value="<?php $this->remember('author'); ?>" required />
                <span class="material-input"></span>
              </div>
            </div>
          </div>
          <div class="form-group">
            <label for="mail"<?php if ($this->options->commentsRequireMail): ?> class="col-sm-2 control-label required"<?php endif; ?>><?php _e('Email'); ?></label>
            <div class="col-sm-9">
              <div class="form-control-wrapper">
                <input type="email" name="mail" id="mail" class="form-control text empty" value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
                <span class="material-input"></span>
              </div>
            </div>
          </div>
          <div class="form-group">
            <label for="url" class="col-sm-2 control-label required" <?php if ($this->options->commentsRequireURL): ?> <?php endif; ?>><?php _e('网站'); ?></label>
            <div class="col-sm-9">
              <div class="form-control-wrapper">
                <input type="url" name="url" id="url" class="form-control text empty" placeholder="<?php _e('http://'); ?>" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
                <span class="material-input"></span>
              </div>
            </div>
          </div>
        <?php endif; ?>
        
        <div class="form-group">
          <label for="textarea" class="col-sm-2 control-label required"><?php _e('内容'); ?></label>
          <div class="col-sm-9">
            <div class="form-control-wrapper">
              <textarea rows="9" cols="50" name="text" id="textarea" class="form-control textarea  empty" required ><?php $this->remember('text'); ?></textarea>
              <span class="material-input"></span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-5">
            <button type="submit" id="submit" class="btn btn-success btn-raised submit"><?php _e('提交评论'); ?><div class="ripple-wrapper"></div></button>
          </div>
          <input type="hidden" name="_" value="70e80f45f398751adf2243497d864ab0">
        </div>
      </form>
    </div>
  </div>
  <?php else: ?>
    <div class="alert alert-warning">评论已关闭</div>
  <?php endif; ?>
</div>
